﻿@using System.Data;
@model DTcms.Model.BaseModel
@{
    ViewBag.Title = "会员登录-" + Model.site.name;
    string templateskin = Model.templateskin;
    string turl = Model.info["turl"].ToString();
}
@section HeaderContent{

}
<!--当前位置-->
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@Html.linkurl("index")">首页</a> &gt;
        <a href="@Html.linkurl("login")">会员登录</a>
    </div>
</div>
<!--/当前位置-->
<!--导航推荐-->
<div class="section">
    <div class="wrapper">
        <div class="bg-wrap">
            <div class="nav-tit">
                <a class="selected" href="javascript:;">账户登录</a>
                <i>|</i>
                <a href="@Html.linkurl("register")">免费注册</a>
            </div>
            <form id="loginform" name="loginform" class="login-box layui-form">
                <input name="site_id" value="@Model.site.id" type="hidden" />
                <div class="input-box">
                    <input id="txtUserName" name="txtUserName" type="text" placeholder="用户名/手机/邮箱" maxlength="50" lay-verType="tips" lay-verify="required" required />
                </div>
                <div class="input-box">
                    <input id="txtPassword" name="txtPassword" type="password" placeholder="输入登录密码" maxlength="16" lay-verType="tips" lay-verify="required" required />
                </div>
                <div class="remember-box">
                    <input id="chkRemember" name="chkRemember" type="checkbox" value="true" title="记住登录状态" lay-skin="primary"/>
                    <a class="linkABlue" href="@Html.linkurl("repassword")">忘记密码?</a>
                </div>
                <div class="btn-box">
                    <button class="layui-btn" lay-filter="btnSubmit" lay-submit>立即登录</button>
                </div>
                <div class="oatuh-box">
                    <h3>您还可以使用以下方式登录：</h3>
                    <p>
                        @{
                            DataTable oauthList = Html.get_site_oauth_list(0, "site_id=" + Model.site.id);
                            foreach (DataRow dr in oauthList.Rows)
                            {
                                <a title="@dr["title"]" href="/api/oauth/index.aspx?id=@dr["id"]">
                                    <img src="@dr["img_url"]" />
                                </a>
                            }
                        }
                    </p>
                </div>
            </form>
            <input id="turl" name="turl" type="hidden" value="@turl" /><!--记住上一页网址-->
        </div>
    </div>
</div>
<div class="reg_tip" id="have_login" style="display:none;">
    <div class="pic"><img src="/template/pc/main/default/images/temp_08091512519636.gif" alt=""></div>
    <div class="txt">请稍等，系统正在处理登录中...</div>
</div>
@section Scripts{
    <script type="text/javascript">
        layui.use(['form'], function () {
            var form = layui.form;
            form.on('submit(btnSubmit)', function (data) {
                var load = layer.load(2);
                if (!data.field.chkRemember) {
                    data.field.chkRemember = 0;
                }
                $.ajax({
                    url: '/api/submit_ajax/user_login',
                    data: data.field,
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        layer.close(load);
                        if (res.status == 1) {
                            if (typeof (res.url) == "undefined") {
                                location.href = $("#turl").val();
                            } else {
                                location.href = res.url;
                            }
                        } else {
                            layer.msg(res.msg);
                        }
                        if (typeof (res.url) != "undefined") {
                            location.href = res.url;
                        }
                    }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                        layer.close(load);
                        layer.msg("状态：" + textStatus + "；出错提示：" + errorThrown);
                    }
                });
                return false;
            });
        });
    </script>
}